<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow: flow::log::Async_file_logger::Log_request Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow project: Full implementation reference.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceflow.html">flow</a></li><li class="navelem"><a class="el" href="namespaceflow_1_1log.html">log</a></li><li class="navelem"><a class="el" href="classflow_1_1log_1_1Async__file__logger.html">Async_file_logger</a></li><li class="navelem"><a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html">Log_request</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="structflow_1_1log_1_1Async__file__logger_1_1Log__request-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">flow::log::Async_file_logger::Log_request Struct Reference</div></div>
</div><!--header-->
<div class="contents">

<p>In addition to the task object (function) itself, these are the data placed onto the queue of <code>m_async_worker</code> tasks for a particular <code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#aa557c0f55c1044161acc8fb54c115a3e" title="Implements interface method by asynchronously logging the message and some subset of the metadata in ...">do_log()</a></code> call, to be used by that task and then freed immediately upon logging of the message to file.  
 <a href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#details">More...</a></p>
<div class="dynheader">
Collaboration diagram for flow::log::Async_file_logger::Log_request:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="structflow_1_1log_1_1Async__file__logger_1_1Log__request__coll__graph.svg" width="1092" height="399"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-attribs" name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a82a13a6d045612578dad42a82de36202"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202">m_msg_copy</a></td></tr>
<tr class="memdesc:a82a13a6d045612578dad42a82de36202"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to array of characters comprising a copy of <code>msg</code> passed to <code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#aa557c0f55c1044161acc8fb54c115a3e" title="Implements interface method by asynchronously logging the message and some subset of the metadata in ...">do_log()</a></code>. We must <code>delete[]</code> it.  <a href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202">More...</a><br /></td></tr>
<tr class="separator:a82a13a6d045612578dad42a82de36202"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a43b7a817420a80d955e4acfd0ec10f45"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a43b7a817420a80d955e4acfd0ec10f45">m_msg_size</a></td></tr>
<tr class="memdesc:a43b7a817420a80d955e4acfd0ec10f45"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of characters in <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete[] it.">m_msg_copy</a> pointee string.  <a href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a43b7a817420a80d955e4acfd0ec10f45">More...</a><br /></td></tr>
<tr class="separator:a43b7a817420a80d955e4acfd0ec10f45"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7215d35008420d5c3357df1b06761d64"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structflow_1_1log_1_1Msg__metadata.html">Msg_metadata</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a7215d35008420d5c3357df1b06761d64">m_metadata</a></td></tr>
<tr class="memdesc:a7215d35008420d5c3357df1b06761d64"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to array of characters comprising a copy of <code>msg</code> passed to <code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#aa557c0f55c1044161acc8fb54c115a3e" title="Implements interface method by asynchronously logging the message and some subset of the metadata in ...">do_log()</a></code>. We must <code>delete</code> it.  <a href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a7215d35008420d5c3357df1b06761d64">More...</a><br /></td></tr>
<tr class="separator:a7215d35008420d5c3357df1b06761d64"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aee7f652b0e17e39d0afdb721bc956cf7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbool.html">bool</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#aee7f652b0e17e39d0afdb721bc956cf7">m_throttling_begins</a></td></tr>
<tr class="memdesc:aee7f652b0e17e39d0afdb721bc956cf7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Whether this log request was such that its memory footprint (<code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#a6d74d81cb726a30f33f4fc106e3be5b6" title="How much do_log() issuing the supplied Log_request shall contribute to m_pending_logs_sz.">mem_cost()</a></code>) pushed <code>m_pending_logs_sz</code> from <code>&lt; m_throttling_cfg.m_hi_limit</code> to <code>&gt;= m_throttling_cfg.m_hi_limit</code> for the first time since it was last equal to zero.  <a href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#aee7f652b0e17e39d0afdb721bc956cf7">More...</a><br /></td></tr>
<tr class="separator:aee7f652b0e17e39d0afdb721bc956cf7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >In addition to the task object (function) itself, these are the data placed onto the queue of <code>m_async_worker</code> tasks for a particular <code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#aa557c0f55c1044161acc8fb54c115a3e" title="Implements interface method by asynchronously logging the message and some subset of the metadata in ...">do_log()</a></code> call, to be used by that task and then freed immediately upon logging of the message to file. </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#a6d74d81cb726a30f33f4fc106e3be5b6" title="How much do_log() issuing the supplied Log_request shall contribute to m_pending_logs_sz.">mem_cost()</a>.</dd></dl>
<h3>Rationale/details</h3>
<p >The object is movable which is important. It is also copyable but only because, as of this writing, C++17 requires captures by value to be copyable (in order to compile), even though this is <em>not executed at runtime</em>, unless one actually needs to make a copy of the function object (which we avoid like the plague).</p>
<p >We try hard &ndash; harder than in most situations &ndash; to keep the memory footprint of this thing as small as possible, right down to even avoiding a <code>shared_ptr</code>, when a raw or <code>unique_ptr</code> is enough; and not storing the result of <a class="el" href="classflow_1_1log_1_1Async__file__logger.html#a6d74d81cb726a30f33f4fc106e3be5b6" title="How much do_log() issuing the supplied Log_request shall contribute to m_pending_logs_sz.">mem_cost()</a> (but rather recomputing it inside the <code>m_async_worker</code> task). That is because of the same memory use potential problem with which the throttling feature (see <a class="el" href="classflow_1_1log_1_1Async__file__logger.html" title="An implementation of Logger that logs messages to a given file-system path but never blocks any loggi...">Async_file_logger</a> class doc header) grapples.</p>
<p >Ideally each item stored here has RAII semantics, meaning once the object is destroyed, the stuff referred-to therein is destroyed. However you'll notice this is not the case at least for <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a7215d35008420d5c3357df1b06761d64" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete it.">m_metadata</a> and for <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete[] it.">m_msg_copy</a>. Therefore the function body (the <code>m_async_worker</code> task for this <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html" title="In addition to the task object (function) itself, these are the data placed onto the queue of m_async...">Log_request</a>) must manually <code>delete</code> these objects from the heap. Moreover, if the lambda were to never run (e.g., if we destroyed or stopped <code>m_async_worker</code> while tasks are still enqueued), those objects would get leaked. (As of this writing we always flush the queue in <a class="el" href="classflow_1_1log_1_1Async__file__logger.html" title="An implementation of Logger that logs messages to a given file-system path but never blocks any loggi...">Async_file_logger</a> dtor for this and another reason.)</p>
<p >So why not just use <code>unique_ptr</code> then? The reason is above: they're not copyable, and we need it to be, as otherwise C++17 won't let <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html" title="In addition to the task object (function) itself, these are the data placed onto the queue of m_async...">Log_request</a> be value-captured in lambda. One can use <code>shared_ptr</code>; this is elegant, but at this point we're specifically trying to reduce the RAM use to the bare minimum, so we avoid even the tiny control block size of <code>shared_ptr</code>. For <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete[] it.">m_msg_copy</a> one could have used <code>std::string</code> or <a class="el" href="classflow_1_1util_1_1Basic__blob.html" title="A hand-optimized and API-tweaked replacement for vector&lt;uint8_t&gt;, i.e., buffer of bytes inside an all...">util::Basic_blob</a> or <code>std::vector</code>, but they all have some extra members we do not need (size on top of capacity; <code>Basic_blob</code> also has <code>m_start</code>). (<a class="el" href="classflow_1_1util_1_1Basic__blob.html" title="A hand-optimized and API-tweaked replacement for vector&lt;uint8_t&gt;, i.e., buffer of bytes inside an all...">util::Basic_blob</a> doc header as of this writing has a to-do to implement a <code>Tight_blob</code> class with just the pointer and capacity, no extras; so that would have been useful.) Even with those options, that would've still left <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a7215d35008420d5c3357df1b06761d64" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete it.">m_metadata</a>. One could write little wrapper classes for both the string blob <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete[] it.">m_msg_copy</a> and/or <a class="el" href="structflow_1_1log_1_1Msg__metadata.html" title="Simple data store containing all of the information generated at every logging call site by flow::log...">Msg_metadata</a> <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a7215d35008420d5c3357df1b06761d64" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete it.">m_metadata</a>, and that did work. Simply put, however, storing the rare raw pointers and then explicitly <code>delete</code>ing them in one spot is just much less boiler-plate.</p>
<dl class="section warning"><dt>Warning</dt><dd>Just be careful with maintenance. Tests should indeed try to force the above leak and use sanitizers (etc.) to ensure it is avoided. </dd></dl>

<p class="definition">Definition at line <a class="el" href="async__file__logger_8hpp_source.html#l00610">610</a> of file <a class="el" href="async__file__logger_8hpp_source.html">async_file_logger.hpp</a>.</p>
</div><h2 class="groupheader">Member Data Documentation</h2>
<a id="a7215d35008420d5c3357df1b06761d64" name="a7215d35008420d5c3357df1b06761d64"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7215d35008420d5c3357df1b06761d64">&#9670;&nbsp;</a></span>m_metadata</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structflow_1_1log_1_1Msg__metadata.html">Msg_metadata</a>* flow::log::Async_file_logger::Log_request::m_metadata</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Pointer to array of characters comprising a copy of <code>msg</code> passed to <code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#aa557c0f55c1044161acc8fb54c115a3e" title="Implements interface method by asynchronously logging the message and some subset of the metadata in ...">do_log()</a></code>. We must <code>delete</code> it. </p>

<p class="definition">Definition at line <a class="el" href="async__file__logger_8hpp_source.html#l00621">621</a> of file <a class="el" href="async__file__logger_8hpp_source.html">async_file_logger.hpp</a>.</p>

<p class="reference">Referenced by <a class="el" href="async__file__logger_8cpp_source.html#l00457">flow::log::Async_file_logger::deep_size()</a>.</p>

</div>
</div>
<a id="a82a13a6d045612578dad42a82de36202" name="a82a13a6d045612578dad42a82de36202"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a82a13a6d045612578dad42a82de36202">&#9670;&nbsp;</a></span>m_msg_copy</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* flow::log::Async_file_logger::Log_request::m_msg_copy</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Pointer to array of characters comprising a copy of <code>msg</code> passed to <code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#aa557c0f55c1044161acc8fb54c115a3e" title="Implements interface method by asynchronously logging the message and some subset of the metadata in ...">do_log()</a></code>. We must <code>delete[]</code> it. </p>

<p class="definition">Definition at line <a class="el" href="async__file__logger_8hpp_source.html#l00615">615</a> of file <a class="el" href="async__file__logger_8hpp_source.html">async_file_logger.hpp</a>.</p>

</div>
</div>
<a id="a43b7a817420a80d955e4acfd0ec10f45" name="a43b7a817420a80d955e4acfd0ec10f45"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a43b7a817420a80d955e4acfd0ec10f45">&#9670;&nbsp;</a></span>m_msg_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t flow::log::Async_file_logger::Log_request::m_msg_size</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Number of characters in <a class="el" href="structflow_1_1log_1_1Async__file__logger_1_1Log__request.html#a82a13a6d045612578dad42a82de36202" title="Pointer to array of characters comprising a copy of msg passed to do_log(). We must delete[] it.">m_msg_copy</a> pointee string. </p>

<p class="definition">Definition at line <a class="el" href="async__file__logger_8hpp_source.html#l00618">618</a> of file <a class="el" href="async__file__logger_8hpp_source.html">async_file_logger.hpp</a>.</p>

<p class="reference">Referenced by <a class="el" href="async__file__logger_8cpp_source.html#l00457">flow::log::Async_file_logger::deep_size()</a>.</p>

</div>
</div>
<a id="aee7f652b0e17e39d0afdb721bc956cf7" name="aee7f652b0e17e39d0afdb721bc956cf7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aee7f652b0e17e39d0afdb721bc956cf7">&#9670;&nbsp;</a></span>m_throttling_begins</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbool.html">bool</a> flow::log::Async_file_logger::Log_request::m_throttling_begins</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Whether this log request was such that its memory footprint (<code><a class="el" href="classflow_1_1log_1_1Async__file__logger.html#a6d74d81cb726a30f33f4fc106e3be5b6" title="How much do_log() issuing the supplied Log_request shall contribute to m_pending_logs_sz.">mem_cost()</a></code>) pushed <code>m_pending_logs_sz</code> from <code>&lt; m_throttling_cfg.m_hi_limit</code> to <code>&gt;= m_throttling_cfg.m_hi_limit</code> for the first time since it was last equal to zero. </p>

<p class="definition">Definition at line <a class="el" href="async__file__logger_8hpp_source.html#l00628">628</a> of file <a class="el" href="async__file__logger_8hpp_source.html">async_file_logger.hpp</a>.</p>

</div>
</div>
<hr/>The documentation for this struct was generated from the following file:<ul>
<li>log/<a class="el" href="async__file__logger_8hpp_source.html">async_file_logger.hpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 28 2025 22:55:35 for Flow by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
